package com.bringway.p2p.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.bringway.p2p.dao.P2pDqscDao;
import com.bringway.p2p.service.P2pDqscService;

import net.sf.json.JSONObject;
@Service
public class P2pDqscServiceImpl implements P2pDqscService{
	@Autowired
	private P2pDqscDao p2pDqscDao;

	@Override
	public List<Map<String, Object>> queryProListAll(JSONObject params) {
		return p2pDqscDao.queryProListAll(params);
	}

	@Override
	public int getCount(JSONObject params) {
		return p2pDqscDao.getCount(params);
	}

	@Override
	public boolean insertPro(Map<String, Object> paramMap) {
		return p2pDqscDao.insertPro(paramMap)>0;
	}

	@Override
	public List<Map<String, Object>> queryShdzListAll(JSONObject params) {
		return p2pDqscDao.queryShdzListAll(params);
	}

	@Override
	public int getShdzListCount(JSONObject params) {
		return p2pDqscDao.getShdzListCount(params);
	}

	@Override
	public List<Map<String, Object>> queryGwcListAll(JSONObject params) {
		return p2pDqscDao.queryGwcListAll(params);
	}

	@Override
	public int getGwcCount(JSONObject params) {
		return p2pDqscDao.getGwcCount(params);
	}

	@Override
	public List<Map<String, Object>> queryOrderListAll(JSONObject params) {
		return p2pDqscDao.queryOrderListAll(params);
	}

	@Override
	public int getOrderCount(JSONObject params) {
		return p2pDqscDao.getOrderCount(params);
	}

	@Override
	public String getSumOrderJe(JSONObject params) {
		return p2pDqscDao.getSumOrderJe(params);
	}

	@Override
	public List<Map<String, Object>> queryOrderProList(String orderbh) {
		return this.p2pDqscDao.queryOrderProList(orderbh);
	}

	@Override
	public int getOrderProCount(String orderbh) {
		return p2pDqscDao.getOrderProCount(orderbh);
	}

	@Override
	public boolean updateOrderKdxx(JSONObject params) {
		return p2pDqscDao.updateOrderKdxx(params)>0;
	}

	@Override
	public boolean updatePro(Map<String, Object> paramMap) {
		return p2pDqscDao.updatePro(paramMap)>0;
	}

	@Override
	public boolean updateOrderOver(JSONObject params) {
		return p2pDqscDao.updateOrderOver(params)>0;
	}

	@Override
	public List<Map<String, Object>> exportOrderExcelMethod(JSONObject params) {
		List<Map<String, Object>> list=p2pDqscDao.queryOrderListAll(params);
		for (Map<String, Object> map : list) {
			List<Map<String, Object>> list2=p2pDqscDao.queryOrderProList(MapUtils.getString(map, "ORDER_BH"));
			List<String> pStrings=new ArrayList<>();
			for (Map<String, Object> map2 : list2) {
				String pString=MapUtils.getString(map2, "PRODUCT_NAME")+"("+MapUtils.getString(map2, "PRODUCT_NUM")+")";
				pStrings.add(pString);
			}
			map.put("PROXX", pStrings.toString());
		}
		return list;
	}

	
	@Override
	public List<Map<String, Object>> exportOrderExcelMethod1(JSONObject params) {
		List<Map<String, Object>> list=p2pDqscDao.queryOrderListAll(params);
		List<Map<String, Object>> list3=new ArrayList<>();
		for (Map<String, Object> map : list) {
			List<Map<String, Object>> list2=p2pDqscDao.queryOrderProList(MapUtils.getString(map, "ORDER_BH"));
			for (Map<String, Object> map2 : list2) {
				Map<String, Object> map3=new HashMap<String, Object>();
				map3.putAll(map);
				map3.putAll(map2);
				list3.add(map3);
			}
		}
		return list3;
	}

	@Override
	public List<Map<String, Object>> queryCheckDqList(JSONObject params) {
		return p2pDqscDao.queryCheckDqList(params);
	}

	@Override
	public int getCheckDqCount(JSONObject params) {
		return p2pDqscDao.getCheckDqCount(params);
	}
	
}
